home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / vg-2.03 / video / trident.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.1 KB  |  112 lines

  1. /*
  2.  * Copyright (C) 1990-1992 by Michael Davidson.
  3.  * All rights reserved.
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software
  6.  * and its documentation for any purpose and without fee is hereby
  7.  * granted, provided that the above copyright notice appear in all
  8.  * copies and that both that copyright notice and this permission
  9.  * notice appear in supporting documentation.
  10.  *
  11.  * This software is provided "as is" without express or implied warranty.
  12.  */
  13.  
  14. /*
  15.  * trident.c    - support routines for Trident 8800 and 8900
  16.  */
  17.  
  18. #include    "vdev.h"
  19. #include    "svga.h"
  20.  
  21. /*
  22.  * table of video modes supported for Trident 8800 and 8900
  23.  */
  24. #define    GRAPHICS    (SVGA_MODE_SUPPORTED | SVGA_GRAPHICS_MODE)
  25. #define    TEXT        (SVGA_MODE_SUPPORTED | SVGA_TEXT_MODE)
  26.  
  27. static struct svga_mode_info trident_modes[] =
  28. {
  29.     {    1024,    768,    8,    0x62,    GRAPHICS },
  30.     {    800,    600,    8,    0x5e,    GRAPHICS },
  31.     {    640,    480,    8,    0x5d,    GRAPHICS },
  32.     {    640,    400,    8,    0x5c,    GRAPHICS },
  33.     {    320,    200,    8,    0x13,    GRAPHICS },
  34.     {    132,    30,    0,    0x54,    TEXT     },
  35.     {    80,    25,    0,    0x03,    TEXT     },
  36.     {    0,    0,    0,    0x00,    0        }
  37. };
  38.  
  39. static void    trident_bank_switch();
  40. static int    trident_present();
  41.  
  42. /*ARGSUSED*/
  43. int
  44. trident_init(
  45.     char    *name,
  46.     struct vdev *v
  47.     )
  48. {
  49.     int        r;
  50.  
  51.     if (! (r = trident_present()))
  52.     return -1;
  53.  
  54.     svga_setup(v, trident_modes, trident_bank_switch);
  55.  
  56.     v->v_name        = (r == 8900)    ? "Trident 8900"
  57.                     : "Trident 8800";
  58.     return 0;
  59. }
  60.  
  61. int
  62. trident_probe()
  63. {
  64.     return trident_present();
  65. }
  66.  
  67. static int
  68. trident_present()
  69. {
  70.     int        old;
  71.     int        new;
  72.  
  73.     outb(0x3c4, 0x0e);
  74.     old    = inb(0x3c5);
  75.     outb(0x3c5, 0x00);
  76.     new    = inb(0x3c5) & 0x0f;
  77.     outb(0x3c5, old);
  78.     if (new != 0x02)
  79.     return 0;        /* not trident */
  80.  
  81.     outb(0x3c4, 0x0b);
  82.     outb(0x3c5, 0x00);
  83.     new    = inb(0x3c5);
  84.  
  85.     if (new >= 0x03)
  86.     return 8900;
  87.     else
  88.     return 8800;
  89. }
  90.  
  91. /*
  92.  * trident_bank_switch()
  93.  */
  94. static void
  95. trident_bank_switch(
  96.     int        x
  97.     )
  98. {
  99.     int        z;
  100.  
  101.     outb(0x3ce, 0x06);
  102.     z = inb(0x3cf);
  103.     outb(0x3ce, 0x06);
  104.     outb(0x3cf, (z & 0xf3) | 4);
  105.  
  106.     outb(0x3c4, 0x0b);
  107.     inb(0x3c5);
  108.  
  109.     outb(0x3c4, 0x0e);
  110.     outb(0x3c5, x ^ 0x02);
  111. }
  112.